# 客户端
import socket

client_sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip_port = ("127.0.0.1", 8080)
client_sk.connect(ip_port)

# 给服务端发送消息
client_sk.send('hello server'.encode('utf-8'))

# 接受服务端发生过来的消息
ret = client_sk.recv(1024).decode('utf-8')
print('服务端发来贺电:', ret)

client_sk.close()